<?php
class StudentClass extends Zend_Db_Table
{
	protected $_name ="student_class";
	protected $_primary = 'id';

 //根据id 查询student_class
    public function getstudent_classByid($id){
          $select = $this->select();
          $select->where("id=".$id);
          return $this->fetchAll($select)->toArray();
    }
 //根据id 查询student_class
    public function getstudent_classBystudent_id($student_id){
          $select = $this->select();
          $select->where("student_id=".$student_id);
		  $select->order('class_id desc');
          return $this->fetchAll($select)->toArray();
    }
     //根据class_id 查询student_class
    public function getstudent_classByclass_id($class_id,$page,$perpage){
          $select = $this->select();
          $select->where("class_id=".$class_id);
          if($page!=9999){
				$select->limitPage($page,$perpage);
			}
          return $this->fetchAll($select)->toArray();
    }

 //更新student_class
    public function updatestudent_classByid($array,$id){

		$db = $this->getAdapter();
		$where=$db->quoteInto('id = ?', $id);
		$this->update($array, $where);
		return true;
	}
//删除student_class
     public function delstudent_classByid($id){
          $where = 'id = '. $id;
         $this->delete($where);
         return true;
    }
//删除student_class
     public function delstudent_classBystudent_id($student_id){
          $where = 'student_id = '. $student_id;
         $this->delete($where);
         return true;
    }
	
	public function updateStudentClass($array,$student_id,$class_id){
		$db = $this->getAdapter();
		$where = " student_id=".$student_id." and class_id=".$class_id; 
		$this->update($array, $where);
		return true;
	}
	
	public function getAll(){
		$select = $this->select();
		return $this->fetchAll($select)->toArray();
	}
	


}

